package Oct_2020_BETA.part5;

import java.util.*;

public class Oco {
    public static void main(String[] args) {
//        arrayList数组维护了一个Object【】element
        LinkedList<Integer> list=new LinkedList<>();
        list.add(56);
        list.add(89);
        list.add(100);
        list.add(2017);
        view_all(list);
        delete(list,2);
        view_all(list);
        addFirst(list,69);
        addLast(list,"fdfd");
        view_all(list);
        list.removeFirst();
        view_all(list);
//set无序+不能重复,自动去重，存在空值
        Set<java.io.Serializable> set=new HashSet<>();
        set.add(36);
        set.add(12);
        set.add("123");
        set.add(true);
        set.add('k');
        view_all(set);
        System.out.println(set);
        Iterator<java.io.Serializable> iterator=set.iterator();
        System.out.println(iterator.next());
        view_allp(set);

        Map<Integer,String> map=new HashMap<>();
        map.put(0,"lisa");
        map.put(1,"hello");
        map.put(2,"lolita");
        System.out.println(map);
        System.out.println(map.containsKey(2
        ));
        System.out.println(map.containsValue("hello"));
        System.out.println(map.equals(map));
        map.putAll(map);//复制所有映射到指定映射
        System.out.println("entry "+map.entrySet());
        System.out.println("key "+map.keySet());

        vi(map);
        System.out.println(map.values());;


        Set<Map.Entry<Integer,String>> set1=new HashSet<>();
    }
    public static void view_all(Collection list){
        for (Object o:list){
            System.out.print(o+" ");
        }
        System.out.println("\n");
    }
    public static void delete(List<Integer> list, int a){
        list.remove(a);
    }
    public static void addFirst(List list, Object o){
        list.set(0,o);
    }
    public static void addLast(List list, Object o){
        list.set(list.size()-1,o);
    }
    public static void mp(){
        Set set=new HashSet();

    }
    public static void view_allp(Collection<java.io.Serializable> list){

        for (java.io.Serializable serializable : list) {
//if (iterator.next()!=null)
            System.out.println(serializable);
        }
    }
    public static void vi(Map<Integer, String> m){
       Set<Integer> s1= m.keySet();
       Set<Map.Entry<Integer, String>> s2= m.entrySet();
       view_all(s1);
       view_all(s2);
    }
}
